<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TPosition" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TPosition" type="EIA.Basic.Model.TPosition, EIA.Basic.Model" />
</alias>

<resultMaps>
<resultMap id="select-tposition-result" class="TPosition">
<constructor>
    <argument argumentName="pos_id" column="pos_id"/>
    <argument argumentName="pos_level" column="pos_level"/>
    <argument argumentName="pos_name" column="pos_name"/>
    <argument argumentName="pos_des" column="pos_des"/>
</constructor>
<!--
    <result property="PosId" column="pos_id"/>
    <result property="PosLevel" column="pos_level"/>
    <result property="PosName" column="pos_name"/>
    <result property="PosDes" column="pos_des"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TPosition_where_pk">
WHERE pos_id=#PosId#
</sql>

<sql id="sql_TPosition_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="PosId" prepend="AND">pos_id=#PosId#</isPropertyAvailable>
    <isPropertyAvailable property="PosLevel" prepend="AND">pos_level=#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend="AND">pos_name LIKE concat('%', #PosName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="PosDes" prepend="AND">pos_des LIKE concat('%', #PosDes#, '%')</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TPosition_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="PosLevel" prepend=",">pos_level=#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">pos_name=#PosName#</isPropertyAvailable>
    <isPropertyAvailable property="PosDes" prepend=",">pos_des=#PosDes#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTPosition" parameterClass="" resultMap="TPosition.select-tposition-result">
SELECT *
FROM t_position
<include refid="sql_TPosition_where_pk"/><!--where-->
</select>

<select id="SelectTPosition_CV" parameterClass="System.Collections.IDictionary" resultMap="TPosition.select-tposition-result">
SELECT *
FROM t_position
<include refid="sql_TPosition_where_cv"/><!--where-->
</select>

<insert id="InsertTPosition" parameterClass="TPosition">
<!--pre selectKey place-->
INSERT INTO t_position(
<dynamic prepend=" ">
    <isPropertyAvailable property="PosLevel" prepend=",">pos_level</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">pos_name</isPropertyAvailable>
    <isPropertyAvailable property="PosDes" prepend=",">pos_des</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="PosLevel" prepend=",">#PosLevel#</isPropertyAvailable>
    <isPropertyAvailable property="PosName" prepend=",">#PosName#</isPropertyAvailable>
    <isPropertyAvailable property="PosDes" prepend=",">#PosDes#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="PosId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTPosition" parameterClass="System.Collections.IDictionary">
UPDATE t_position
<include refid="sql_TPosition_set_cols"/><!--set-->
<include refid="sql_TPosition_where_pk"/><!--where-->
</update>

<delete id="DeleteTPosition" parameterClass="">
DELETE FROM t_position
<include refid="sql_TPosition_where_pk"/><!--where-->
</delete>

<statement id="DeleteTPosition_CV" parameterClass="TPosition">
DELETE FROM t_position
<include refid="sql_TPosition_where_cv"/><!--where-->
</statement>

<delete id="ClearTPosition">
DELETE FROM t_position
</delete>
</statements>
</sqlMap>